﻿using System;
using System.Collections.Generic;
using Utility.Config;

//----------------------------------------------------------------*/
// 版权所有：
// 文 件 名：DBConfig.cs
// 功能描述：数据库配置类
// 创建标识：m.sh.lin0328@163.com 2014/7/10 22:16:34
// 修改描述：
//----------------------------------------------------------------*/
namespace DataBase.Common
{
    public class DBConfig
    {
        private static Common.SqlSourceType _databaseType = Common.SqlSourceType.SQLServer;
        private static string _logName = "SQLServerLog";// + DateTime.Now.ToString("yyyy-MM-dd");
        private static string _connString = "";
        private static bool _isEncrypt = false;//链接字符串是否加密

        /// <summary>
        /// 数据库链接
        /// </summary>
        public static string ConnString
        {
            get
            {
                if (!String.IsNullOrEmpty(_connString))
                {
                    return _connString;
                }
                try
                {
                    return ConfigHelper.GetAppSettings("DB");
                }
                catch (Exception er)
                {
                    new Exception("Error on WriteLog (配置项不存在):" + er);
                    return null;
                }
            }
            set
            {
                value = _connString;
            }
        }
        public static bool IsEncrypt
        {
            get
            {
                try
                {
                    if (ConfigHelper.GetAppSettings("IsEncrypt") == "true")
                        _isEncrypt = true;

                    return _isEncrypt;
                }
                catch (Exception)
                {
                    //new Exception("Error on WriteLog (配置项不存在):" + er);
                    return false;
                }
            }
        }
        /// <summary>
        /// 日志文件名
        /// </summary>
        public static string LogName
        {
            get { return _logName; }
            set { _logName = value; }
        }
        /// <summary>
        /// 数据库类型
        /// </summary>
        public static Common.SqlSourceType DatabaseType
        {
            get { return _databaseType; }
            set { _databaseType = value; }
        }
    }
}
